package com.itheima.d1_exception;

public class Student extends Exception {
    private int age;

    public Student() {
    }

    public Student(String message) {
        super(message);
    }

    public Student(String message, Throwable cause) {
        super(message, cause);
    }

    public Student(Throwable cause) {
        super(cause);
    }

    public Student(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws Exception {
        if (age > 150 || age < 0) {
            throw new Exception("年龄不合法");
        }
        this.age = age;
    }
}
